package com.dyh.quickdemo.Spy;

import org.junit.jupiter.api.Test;

/*
@Author=Joey Wheeler
@Date=2021/4/13 18:04
*/
public class SpyDemo {

    @Test
    public void test(){
        f1(1L);
    }

    public void f1(long l){
        String str = "dawd";
        Spy spy = new BaseSpy(System.out::println);
        SpyHeadquarters.watch("pushOrder",spy);

            f2(str,l);

        spy.doReport();
        SpyHeadquarters.withdraw("pushOrder");
    }

    public void f2(String s,long l){
        Spy spy = SpyHeadquarters.get("pushOrder");
        spy.addRecord("l="+l);
        spy.addRecord("s="+s);

    }
}
